Friedrich Ewald My Personal Website

Posts


  • Memory profiling with Memray

    I am currently working on a small Python project with a relatively large memory footprint. I wanted to analyze the usage in detail and realized that I wasn’t aware of any good Python memory profiler. After some searching I found the builtin package tracemalloc (Trace memory allocation). Especially interesting to me is the capability to take snapshots at different points in time and then compare the delta between those snaphots. The following snippet illustrates this.

    import numpy
    import tracemalloc
    
    tracemalloc.start()
    snapshot_before = tracemalloc.take_snapshot()
    array = numpy.zeros((100, 100))
    array2 = numpy.random.rand(1_000_000, 1_000)
    print(array2.dtype)
    array3 = array2.astype(numpy.float16)
    snapshot_after = tracemalloc.take_snapshot()
    stats = snapshot_after.compare_to(snapshot_before, 'lineno')
    
    for s in stats[:10]:
        print(s)
    print(tracemalloc.get_traced_memory())
    This is fine for smaller code bases where I have full control over the source. It requires however a lot of editing and manual filtering of frames and taking snapshots at the right time. Another interesting solution is Bloombergs memray. This allows to run a whole Python application and save the snapshots into a file. From there memray can either create a table or a flamegraph to see the memory consumption over time. Memray can be used like this:
    pip3 install memray
    
    # Run application and save snapshots
    memray run my_app.py
    
    # Display snapshots
    memray flamegraph memray-test.py.94623.bin
    This generates a HTML file which can be opened in any browser.

  • Updating Jekyll to Ruby 3.2.0

    I recently updated this blog to Ruby 3.2.0 which was released on Dec 25, 2022. I expected this to be a minor update since I came from Ruby 3.1.2. However, I ran into some problems that I had to solve.

    Continue reading

  • Electric Closet

    I never liked having the router in full display in the living room. I routed the fiber connection into a closet in our hallway with the plan on making this a “tech closet”. I had to route electricity to the closet and install some shelves. The goal was to have a space for the router, my printer (that I only use ocassionally), some other hardware like a Raspberry Pi and to be able to charge a Dyson vacuum cleaner. The (almost) finished closet. The cover plate for the outlet was not available at the time. I connected the outlets with Wago connectors before installing them. This avoided having to install the outlets in an awkward position and sped the whole process up significantly. View from below The view from below. I used normal wood screws to attach the boards to the wall. Time will tell if this is sufficient. In case this is not stable enough: Behind the drywall are some studs at exactly the same position. View in the left corner from below Smaller, divided boards I chose to have some board divided in the middle and not spanning the whole depth of the closet. This allows flexibility and also to store bigger items.

  • ChatGPT

    Who are you?

    I am Assistant, a large language model trained by OpenAI to assist with a variety of tasks. I am not a person, but rather a program that uses advanced machine learning algorithms to process and generate text. I am here to provide information and help answer your questions to the best of my ability. Do you have any questions I can help you with?
    Do you have any special skills?
    As a language model, my primary skill is generating and understanding natural language text. I am trained to assist with a variety of tasks, including answering questions, providing information, and engaging in conversation. I am constantly learning and improving my abilities through machine learning, so my capabilities are always expanding. Is there something specific you would like to know or discuss? I would be happy to help with any question or topic you have in mind.
    When being asked about ChatGPT, it doesn’t know itself. Likely because it was trained on data ending in 2021 which is before ChatGPT was published. I recommend trying it out.

    Update Jan 25 2023

    Since a few days, ChatGPT has a premium plan. Anecdotaelly, I just went there and I got a message “ChatGPT is at capacity right now”. It seems like the free days are over.

  • Testing email sending

    I recently came across MailHog. I needed to test some email functionality locally. MailHog creates an SMTP that accepts any email to any address and shows this in web interface.

Page: 2 of 28