Code Monkey home page Code Monkey logo

Comments (9)

Meowhal avatar Meowhal commented on May 29, 2024 1

I added cache cleaner that discard beatmap caches and history caches.
Old history data was wasting memory. They only needed to be kept for a short period of time, but they were kept permanently.
Cleaner will discard them every day.

Lobby#playersMap is also permanently retained, but since i have built the system on the assumption that this data will not be destroyed, safely destroying this data is a difficult task.

As an alternative approach, i changed the app to be launched by node instead of ts-node. This change should help to save some memory.

from osu-ahr.

jramseygreen avatar jramseygreen commented on May 29, 2024

Why don't you just enter things locally to a sqlite database, or even dare I say, a text file

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

Why don't you just enter things locally to a sqlite database, or even dare I say, a text file

yup I've been thinking about this approach. Also I need to investigate this exception I've solved it on #47

C:\Auto Host Rotate\osu-ahr-master\src\webapi\BeatmapRepository.ts:53
        throw new FetchBeatmapError(FetchBeatmapErrorReason.PlayModeMismatched);
              ^
FetchBeatmapError: PlayModeMismatched
    at BeatmapRepositoryClass.getBeatmap (C:\Auto Host Rotate\osu-ahr-master\src\webapi\BeatmapRepository.ts:53:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async MiscLoader.checkMirror (C:\Auto Host Rotate\osu-ahr-master\src\plugins\MiscLoader.ts:92:15) {
  isFetchBeatmapError: true,
  reason: 2
}

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

I tried running 3 rooms for 1 month straight. Got out of memory hahaha 💀 💀 💀

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

Let me try run it without caching the map and I will report back in 1 month.

from osu-ahr.

Meowhal avatar Meowhal commented on May 29, 2024

This is the situation I was afraid of. I'll make it a top priority task when I'm able to write code.

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

This is the situation I was afraid of. I'll make it a top priority task when I'm able to write code.

Yup, I've tried running it without using map as a cache for a day. This is my current implementation, we will see whether it can stay below 1GB memory in 2 weeks

    async getBeatmap(mapId: number, mode: PlayMode = PlayMode.Osu, allowConvert: boolean = true): Promise<BeatmapCache> {
        if (this.fetcher == WebApiClient) {
            if (!WebApiClient.available) {
                this.fetcher = this.websiteFetcher;
            }
        }

        if (WebApiClient.available) {
            /*
            Ah damn I forgot to remove this line. 💀 
           That kinda explain why my network inbound traffic doubled on 1 day
           */
            this.fetcher = this.websiteFetcher;
            let cache = this.tryGetCache(mapId, mode, allowConvert);
            if (cache) return cache;
    
            const set = await this.fetcher.getBeatmapset(mapId);
            if (set.availability.download_disabled == true || set.availability.more_information != null){
                throw new FetchBeatmapError(FetchBeatmapErrorReason.NotAvailable);
            }
            this.cacheMaps(set);
    
            cache = this.tryGetCache(mapId, mode, allowConvert);
            if (cache) return cache;
    
            throw new FetchBeatmapError(FetchBeatmapErrorReason.PlayModeMismatched);
        }
        else{
            const set = await this.fetcher.getBeatmapset(mapId);
            if (set.availability.download_disabled == true || set.availability.more_information != null){
                throw new FetchBeatmapError(FetchBeatmapErrorReason.NotAvailable);
            }
            const now = Date.now();
            for (const map of [...set.beatmaps ?? [], ...set.converts ?? []] as BeatmapCache[]) {
                map.fetchedAt = now;
                map.beatmapset = set;
                map.failtimes = { exit: [], fail: [] };
                //Simplify this
                if(map.id == mapId){
                    if(map.mode_int == PlayMode.Osu.id){
                        if(mode == PlayMode.Osu || (mode != PlayMode.Osu && allowConvert)){
                            return map;
                        }
                    }
                    else{
                        return map;
                    }
                }
            }
            throw new FetchBeatmapError(FetchBeatmapErrorReason.PlayModeMismatched);
        }
    }

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

I tried my approach that I put above, it's still crashed because run out of memory. I will add more RAM to my virtual machine to avoid this problem.

from osu-ahr.

ZeroPyrozen avatar ZeroPyrozen commented on May 29, 2024

This issue has resolved from 6cd9055, thank you so much 😄 .

from osu-ahr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.