-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging callbacks have too much overhead on libmambapy #3415
Comments
Thank you for the report. We have observed a tangential issue for some environments whose resolution via mamba/libmamba/src/solver/libsolv/database.cpp Lines 90 to 108 in 08d7b4e
mamba/libmamba/src/solver/libsolv/database.cpp Lines 110 to 127 in 08d7b4e
mamba/libmamba/src/core/package_database_loader.cpp Lines 31 to 53 in 154012f
An option can be for (release) builds not to emit debug logs unless if explicitly asked by users (with |
#3416 addresses the performance regression. We think that the handling of log levels and of verbosity better be implemented in another PR. |
@jaimergp: can you report if you have observed improvements with 2.0.0rc4? |
In the sense that there are no performance overheads, yes. But I can't seem to be able to invoke obtain the libsolv logs anymore. Isn't this sufficient? libmamba_context = libmambapy.Context(
libmambapy.ContextOptions(
enable_signal_handling=False,
enable_logging=True,
)
)
# Output params
libmamba_context.output_params.json = context.json
if libmamba_context.output_params.json:
libmambapy.cancel_json_output(libmamba_context)
libmamba_context.output_params.quiet = context.quiet
libmamba_context.set_log_level(
{
4: libmambapy.LogLevel.TRACE,
3: libmambapy.LogLevel.DEBUG,
2: libmambapy.LogLevel.INFO,
1: libmambapy.LogLevel.WARNING,
0: libmambapy.LogLevel.ERROR,
}[context.verbosity]
) This ^ correctly gives the params = ChannelResolveParams(
platforms=set(self.subdirs),
channel_alias=CondaURL.parse(str(context.channel_alias)),
custom_channels=ChannelResolveParams.ChannelMap(custom_channels),
custom_multichannels=ChannelResolveParams.MultiChannelMap(custom_multichannels),
home_dir=str(Path.home()),
current_working_dir=os.getcwd(),
)
db = Database(params)
db.set_logger(logger_callback) with def logger_callback(level: libmambapy.solver.libsolv.LogLevel, msg: str, logger=_db_log):
# from libmambapy.solver.libsolv import LogLevel
# levels = {
# LogLevel.Debug: logging.DEBUG, # 0 -> 10
# LogLevel.Warning: logging.WARNING, # 1 -> 30
# LogLevel.Error: logging.ERROR, # 2 -> 40
# LogLevel.Fatal: logging.FATAL, # 3 -> 50
# }
if level.value == 0:
# This incurs a large performance hit!
logger.debug(msg)
else:
logger.log((level.value + 2) * 10, msg) But no luck? |
Yes, we entirely disabled libsolv's logs for now. We need to think about how to properly handle them as well as alternative solvers'. Feel free to open a PR to propose a solution. |
Would it be reasonable to let libsolv print to stderr directly in debug level? |
Probably. Edit: I do not have bandwidth to properly think about it now. |
Not being able to get solver logs from python is quite inconvenient. I had a case this morning where it would have saved me time to have at least some kind of logs. |
In the short-term, we could can consider changing those lines: mamba/libmamba/src/solver/libsolv/database.cpp Lines 112 to 123 in c9c4580
to add such an hard-coded logic for now: const int level = 3;
::pool_setdebuglevel(pool().raw(), level); Alternatively discussions in #2288 need to be resumed. |
Troubleshooting docs
Anaconda default channels
How did you install Mamba?
Mambaforge or latest Miniforge
Search tried in issue tracker
logging debug
Latest version of Mamba
Tried in Conda?
Not applicable
Describe your issue
2.x API includes logging callbacks so the information reported by libsolv or libmamba can be routed through a Python callable via
libmambapy.solver.libsolv.Database.set_logger()
. However, this becomes very slow when thelibsolv
throughput is too large (e.g.verbosity=DEBUG
). It causes a slowdown so large that the solver takes minutes to finish.Are there any ways to have a less resource consuming way? I don't need fancy formatting or full control, just the ability to decide when to send different levels to stdout based on the verbosity chosen by the user.
mamba info / micromamba info
Logs
environment.yml
N/A
~/.condarc
N/A
The text was updated successfully, but these errors were encountered: