Open jaimergp opened 2 months ago
Thank you for the report.
We have observed a tangential issue for some environments whose resolution via libsolv
was hanging due to the logging system. Both issue have the same root cause: all of the possible logs of libsolv
are emitted by default as we set log_level
to std::numeric_limits<int>::max()
.
An option can be for (release) builds not to emit debug logs unless if explicitly asked by users (with verbosity=DEBUG
as you propose).
@jaimergp: can you report if you have observed improvements with 2.0.0rc4?
@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 libmamba
logs, but not for libsolv
. I thought I needed to call set_logger()
on the Database instances:
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 logger_callback()
:
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.
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
~/.condarc